Update Asset
Introduction
Assets may be updated one at a time via the following REST API endpoints:
- PUT /api/v2/assets/{id}
- where {id} is the Assetic unique system GUID for the asset, which may be obtained via the Assetic API GET /api/v2/assets/{id} or GET /api/v2/assets, or via an integration process that created the asset and recorded the GUID.
- PUT /api/v2/components/{id}
- where {id} is the Assetic unique system GUID for the component
- PUT /api/v2/components/{id}/dimensions/{dimensionId}
- where {id} is the Assetic unique system GUID for the component and {dimensionId} is the Assetic unique system GUID for the dimension
Please read the article Asset Integration Overview if unclear about how these endpoints relate to the asset structure in Assetic
There is rate limit applied to the Assetic REST API's which should be considered when attempting to create or update a large number of records.
The process described in Data-Exchange-Integration should be used for data migration projects or large volume transactions.
PUT /api/v2/assets/{id}
Asset Fields
The API PUT /api/v2/assets/{id} updates the asset, which is comprised of the core asset fields and a set of attribute fields relevant to the asset category. Note that some of these non-core asset attribute fields are still common to all categories. The core asset fields are listed in the article Asset Integration Overview. The non-core asset attribute fields are included in the request as an object containing key-value pairs where attribute name is the key.
Full Update Only Supported
The API PUT /api/v2/assets/{id} updates all core attribute fields, so it is important to ensure the PUT /api/v2/assets/{id} payload specifies values for all core fields. It is therefore advisable to first get the asset, so that the fields not being updated can be specified with their current value.
The attribute 'LastModified' returned by GET /api/v2/assets/{id} must be included in the PUT /api/v2/assets/{id} payload since the API will reject the PUT /api/v2/assets/{id} request if the 'LastModified' of the asset is more recent than the 'LastModified' specified in the PUT /api/v2/assets/{id} request. This ensures that if an update to the asset has occurred since the GET /api/v2/assets/{id} request that the current asset attribute values are not be overwritten with out of date values. If this occurs it will be necessary to GET /api/v2/assets/{id} the asset detail again and apply the PUT /api/v2/assets/{id}.
The additional non-core attributes should only be included in the PUT /api/v2/assets/{id} payload if the value is being changed. Non-core attributes that are not specified in the PUT /api/v2/assets/{id} payload will not be updated.
Sample Payload
The following payload updates an asset. Note all core fields are specified, plus 2 attribute fields.
{
"Id": "3a2b0c41-2ce1-e611-946c-06edd62954d7",
"AssetId": "RINT05",
"AssetName": "Kevin Road 5",
"AssetCategory": "Roads",
"AssetCategoryId": "246da33d-6544-e411-82fb-f4b7e2cd8977",
"AssetExternalIdentifier": "ext05",
"LastModified": "2019-03-18T08:20:33",
"AssetClass": "Transport",
"AssetSubClass": "Road",
"AssetType": "Unsealed Road",
"AssetSubType": "Gravel",
"AssetCriticality": "Arterial",
"AssetWorkGroup": "RMPC",
"WorkGroups": [
"RMPC",
"Roads"
],
"Status": "Active",
"AssetMaintenanceType": "Road",
"AssetMaintenanceSubType": "Arterial Road",
"AssetSecurityGroup": null,
"Attributes": {
"Link": "www.assetic.com",
"Comment": "a new comment"
},
"_links": [],
"_embedded": null
}
PUT /api/v2/components/{id}
Component Update
The PUT /api/v2/components/{id} endpoint is used to update component definition.
Sample Payload
The following sample payload updates the component with the GUID "8e439a40-6e1e-e711-946c-06edd62954d7":
URL:
PUT /api/v2/components/8e439a40-6e1e-e711-946c-06edd62954d7
Request Body:
{ "Name": "CP00394806", "ExternalIdentifier": "Ext411142055CMP2", "AssetId": "411142055", "NetworkMeasureType": "Length", "Label": "Formation", "ComponentType": "Formation", "DesignLife": 50, "DimensionUnit": "Metre", "Id": "8e439a40-6e1e-e711-946c-06edd62954d7" }
PUT /api/v2/components/{id}/dimensions/{dimensionId}
Dimension Update
Dimension update requires the GUID of the component and the the GUID of the dimension that is being updated.
Note that partial updates are not supported, so the values for all properties must be included in the payload. It may therefore be necessary to first get the component via the API GET /api/v2/components/{id}/dimensions
Sample Payload
The following sample updates the dimension with GUID "90439a40-6e1e-e711-946c-06edd62954d7". This dimension is in the component with GUID "8e439a40-6e1e-e711-946c-06edd62954d7"
URL:
PUT /api/v2/components/8e439a40-6e1e-e711-946c-06edd62954d7/dimensions/90439a40-6e1e-e711-946c-06edd62954d7
Request Body:
{ "RecordType": "Addition", "NetworkMeasureType": "Length", "Comments": "Created via API", "ComponentId": "8e439a40-6e1e-e711-946c-06edd62954d7", "NetworkMeasure": 50, "Multiplier": 2, "Id": "90439a40-6e1e-e711-946c-06edd62954d7", "Unit": "Metre" }